<template>
  <div class="base-container">
    <t-form ref="form" :data="queryParams" label-width="80" @submit="()=>{this.pagination.current=1;this.queryParams.pageNum=1;this.getList()}" @reset="()=>{this.pagination.current=1;this.queryParams.pageNum=1;this.getList()}">
      <t-row style="border-bottom: 1px solid #E5E6EB;margin-bottom: 10px">
        <t-col :span="11" class="query-form-inline">
          <t-form-item label="成果名称" name="projectName">
            <t-input
              v-model="queryParams.projectName"
              clearable
              placeholder="请输入成果名称"
              style="width: 240px"
            />
          </t-form-item>
          <t-form-item label="成果编号" name="projectNum">
            <t-input
              v-model="queryParams.projectNum"
              clearable
              placeholder="请输入成果编号"
              style="width: 240px"
            />
          </t-form-item>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button theme="primary" type="submit"> 查询</t-button>
          <t-button theme="default" variant="outline" type="reset">重置</t-button>
        </t-col>
      </t-row>
    </t-form>
    <div class="btn-group-inline">
      <t-button @click="dialog.objId=null;dialog.header='新增成果';dialog.open=true" variant="outline" theme="primary">
        <t-icon name="add" slot="icon"/>
        新增成果
      </t-button>
    </div>
    <t-table
      rowKey="id"
      size="small"
      :data="data"
      :columns="columns"
      hover
      :pagination="pagination"
      :loading="dataLoading"
    >

    </t-table>
    <add-edit-result :header="dialog.header" :objId="dialog.objId" :visible.sync="dialog.open"
                     v-if="dialog.open"></add-edit-result>
  </div>
</template>

<script>
import AddEditResult from "./components/add-edit-result.vue";

export default {
  name: "result-unit",
  components:{
    AddEditResult
  },
  data(){
    return {
      dialog: {
        objId: null,
        open: false,
        header: '',
      },
      columns: [
        {
          colKey: "id",
          title: "成果编号",
          align: "center",
        },
        {
          colKey: "projectName",
          title: "成果名称",
          align: "center",
          // ellipsis: true,
        },
        {
          colKey: "projectNum",
          title: "成果类型",
          align: "center",
          // ellipsis: true,
        },
        {
          colKey: "adviceFunding",
          title: "负责人",
          align: "center",
        },
        {
          colKey: "createTime",
          title: "创建时间",
          align: "center",
          // ellipsis: true,
        },
        {
          colKey: "op",
          title: "操作",
          align: "center",
          width: 120,
          fixed: 'right'
        },
      ],
      data: [],
      dataLoading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectCategory: '',
        projectName: '',
        projectType: '',
        projectNum: '',
        projectStatus: '',
        subjectClassification: '',
        dateRange:[],
        sortGroup: '',
        declareDeptName: ''
      },
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0,
        showPageSize: true,
        pageSizeOptions: [10,20,30],
        showFirstAndLastPageBtn: false,
        onChange: (pageInfo) => {
          Object.assign(this.pagination,pageInfo)
          this.queryParams.pageNum = pageInfo.current || 1;
          this.queryParams.pageSize = pageInfo.pageSize;
          this.getList()
        },
      },
    }
  }
}
</script>

<style scoped>

</style>
